<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Question_rent extends CI_Controller {
	function __controller() {
		parent::Controller();
	}

	/**
	 * шаблон для поиск , не задействованный
	 */
	public function index() {
			return;
	}

	######################################  поиск объявлений  ########################################

	/**
	 * форма для поиска по аренде квартир
	 */
	public function flat($idr=false) {
		$data['maps'] =  '';
		

        $output['region']= 7700000000000;
        
		$rg = 'Город Москва';
		$data['region']['title']=''; 
        
        
        
        
        if($idr==false){
		parse_str($_SERVER['QUERY_STRING'], $output);
        }else{
           $output['region']=$idr;
        }
 
 
 

		$data['region']['default'] = $output['region'];

		$this -> load -> model('Views_modul', 'views');
 

		$this -> load -> model('Adsent_modul', 'adsent');

		$output = $this->adsent->rq($output);
		
		
		$data['region']['ar'] =$titles = $this -> adsent -> region();

		if ($output['region'] == 7700000000000) {
			$metros['m'] = $metros['l'] = $this -> adsent -> metrosearch(1);

			$data['maps'] = $this -> load -> view('question/metro/msk', $metros, true);
		}

		if ($output['region'] == 7800000000000) {
			$metros['m'] = $this -> adsent -> metrosearch(2);
			$data['maps'] = $this -> load -> view('question/metro/spb', $metros, true);

		}

 
		
		foreach ($titles as $key => $value) {
			if($value['code']== $output['region']){
				$data['region']['title'] = $rg = $value['fullname'];
			}
		}
		
        if(!isset($rg)){
            $rg = "В Москве";
        }
		$this -> views -> title = 'Поиск объявления по аренде квартир и комнат ' . $rg ;
		
		 
		
		$this -> views -> content = $this -> load -> view('question/rent/flat', $data, true);

		 
		$this -> views -> menu = 'search';
		$this -> views -> left = '';
		$this -> views -> pathway = '';
		
		$this -> views -> head = '';
        
 
        
        
		$content = $this -> views -> request_view();
		$this -> load -> view('home', $content);
	}











	/**
	 * форма для поиска по аренде домов
	 */
	 
	public function suburbian($idr=false) {
		$data['maps'] =   '';
		$rg = 'Город Москва';
		$data['region']['title']='';


        $output['region']= 7700000000000;
        
        if($idr==false){
        parse_str($_SERVER['QUERY_STRING'], $output);
        }else{
           $output['region']=$idr;
        }
 

		$data['region']['default'] = $output['region'];

		$this -> load -> model('Views_modul', 'views');
 
		$this -> load -> model('Adsent_modul', 'adsent');

		$output = $this->adsent->rq($output);
		
		
		$data['region']['ar'] = $titles = $this -> adsent -> region();

		if ($output['region'] == 7700000000000) {
			$metros['m'] = $metros['l'] = $this -> adsent -> metrosearch(1);

			$data['maps'] = $this -> load -> view('question/metro/msk', $metros, true);
		}

		if ($output['region'] == 7800000000000) {
			$metros['m'] = $this -> adsent -> metrosearch(2);
			$data['maps'] = $this -> load -> view('question/metro/spb', $metros, true);

		}






		foreach ($titles as $key => $value) {
			if($value['code']== $output['region']){
				$data['region']['title'] = $rg = $value['fullname'];
			}
		}
		
        if(!isset($rg)){
            $rg = "В Москве";
        }
		$this -> views -> title = 'Поиск объявления по аренде домов и земельных участоков ' . $rg ;
		
		 
		 
		 
		$this -> views -> content = $this -> load -> view('question/rent/suburbian', $data, true);
 
		$this -> views -> menu = 'search';
		$this -> views -> left = '';
		$this -> views -> pathway = '';
		
		$this -> views -> head = '';
        
        
		$content = $this -> views -> request_view();
		$this -> load -> view('home', $content);
	}







	/**
	 * форма для поиска по аренде офисов
	 */
	 
	public function office($idr=false) {
		$data['maps'] =   '';
		

        $output['region']= 7700000000000;
        
		$rg = 'Город Москва';
		$data['region']['title']='';  
        
        
        
        if($idr==false){
        parse_str($_SERVER['QUERY_STRING'], $output);
        }else{
           $output['region']=$idr;
        }

		 
			
			
		$data['region']['default'] = $output['region'];

		$this -> load -> model('Views_modul', 'views');
 
		$this -> load -> model('Adsent_modul', 'adsent');

		$output = $this->adsent->rq($output);

		$data['region']['ar'] = $titles = $this -> adsent -> region();

		if ($output['region'] == 7700000000000) {
			$metros['m'] = $metros['l'] = $this -> adsent -> metrosearch(1);

			$data['maps'] = $this -> load -> view('question/metro/msk', $metros, true);
		}

		if ($output['region'] == 7800000000000) {
			$metros['m'] = $this -> adsent -> metrosearch(2);
			$data['maps'] = $this -> load -> view('question/metro/spb', $metros, true);

		}




		foreach ($titles as $key => $value) {
			if($value['code']== $output['region']){
				$data['region']['title'] = $rg = $value['fullname'];
			}
		}
		
        if(!isset($rg)){
            $rg = "В Москве";
        }
		$this -> views -> title = 'Поиск объявления по аренде коммерческой недвижимости ' . $rg ;
		
		 
		 
		 
		 
		$this -> views -> content = $this -> load -> view('question/rent/office', $data, true);
 
		$this -> views -> menu = 'search';
		$this -> views -> left = '';
		$this -> views -> pathway = '';
		
		$this -> views -> head = '';
        
		$content = $this -> views -> request_view();
		$this -> load -> view('home', $content);
	}


 





}
